<template>
    <div>

        <div class="book_title">
            <h1 align="center">发布任务</h1>
        </div>

        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>系统中心</el-breadcrumb-item>
            <el-breadcrumb-item>发布任务</el-breadcrumb-item>
        </el-breadcrumb>
        <hr>
        <br>
        <el-form :model="inventoryTask" ref="taskForm" label-width="80px">

            <el-form-item label="图书品类" prop="bookDetailedCode">
                <el-select v-model="inventoryTask.bookDetailedCode" placeholder="请选择">
                    <el-option
                            v-for="item in bookDetailed"
                            :label="item.bookName"
                            :key="item.code"
                            :value="item.code">
                    </el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="盘点时间" prop="inventoryTime">
              <!--<el-date-picker
                v-model="inventoryTask.inventoryTime"
                type="date"
                placeholder="选择日期">
              </el-date-picker>-->
              <el-input v-model="inventoryTask.inventoryTime"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="addTask">确 定</el-button>
                <el-button type="info" @click="clearFrom">取 消</el-button>
            </el-form-item>
        </el-form>

    </div>
</template>

<script>
export default {
  name: "markInventoryTask",
  data(){
      return{
          inventoryTask:{
              bookDetailedCode:'',
              inventoryTime:''
          },
          bookDetailed:[],

      }
  },
  methods:{

      clearFrom:function () {
          this.$refs['taskForm'].resetFields();
      },
      getBookDetailed:function () {
          this.$http.post('/book/findAllBookDetailed').then((res)=>{
            console.log(res)
              if(res.data.success){
                  this.bookDetailed=res.data.result.bookDetailedList;
              }
              else {
                  this.$message.error(res.data.message)
              }
          })
      },
      addTask:function () {
          this.$http.post('/markInventoryTask?bookDetailedCode='+this.inventoryTask.bookDetailedCode+'&inventoryTime='+this.inventoryTask.inventoryTime).then((res)=>{
              if(res.data.success){
                  this.$message.success(res.data.message)
                  this.$router.push("/getInventoryTask");
              }else {
                  this.$message.error(res.data.message)
              }
          })
      },
  },
  mounted() {
      this.getBookDetailed();
  }
}
</script>

<style scoped>

</style>
